package Lesson16Homework;

public class Employee 
{
	private String name;
	private Task currentTask;
	private int hoursLeft;
	
	Employee(String name)
	{
		this.name = name;
	}
	
	String getEmployeeName (String name)
	{
		return this.name;
	}
	
	void getEmployeeTask(Task task)
	{
		System.out.println(task.getTaskName());
		System.out.println(task.getWorkinHours());
	}
	
	int getEmployeeHours ()
	{
		return hoursLeft;
	}
	
	void setEmployeeTask(Task task)
	{
		if(this.currentTask == null)
		{
			this.currentTask = task;
		}
	}
	
	private void doneTask()
	{
		this.currentTask = null;
	}
	
	
	
	
	
	void setEmployeeHours( int hoursLeft)
	{
		if(hoursLeft > 0)
		{
			this.hoursLeft = hoursLeft;
		}
	}
	
	void work()
	{
		System.out.println(this.name + " is working!");
		if(this.hoursLeft > this.currentTask.getWorkinHours())
		{
			this.hoursLeft -= this.currentTask.getWorkinHours();
			this.currentTask.setTaskHours(0);	
		}
		else
		{
			this.currentTask.setTaskHours(currentTask.getWorkinHours() - this.hoursLeft);
			this.hoursLeft = 0;
		}
		
		if(this.currentTask.getWorkinHours() == 0)
		{
			System.out.println("Task is done!");
			doneTask();
		}
		System.out.println();
	}
	

 	void showReport()
	{
		System.out.println("======REPORT=======");
		System.out.println("Employee name: " + this.name);
		if(this.currentTask != null)
		{
		System.out.println("Task name: " + this.currentTask.getTaskName());
		}
		if (this.currentTask != null)
		{
		System.out.println("Work current time: " + this.currentTask.getWorkinHours());
		}
		System.out.println("Employee hours left: " + this.hoursLeft);
		System.out.println();
	}

}
